Differences, operation and parameters of the CollectObjects functions of the Object Manager
General information
The CollectObjects functions collect all objects of a class in the database and return them to the
back to the calling party.
Due to the large number of objects, problems have arisen in the various use cases that
have made it necessary to implement several versions.
See also CX_DB_UTLILITY::FindAll
CollectObjects
Collects the objects of the required class with the ObjectStore construct os_dynamic_extent.
This is the most effective method, but there are the following special features:
- the result collection is pointer-based, i.e. it cannot be used after the end of the transaction
- Address space overflow is not handled
Syntax:
nClassID nMode GetManager(OBJECT) Call(CollectObjects) -> collFoundObjects
Name | Meaning | ||||
---|---|---|---|---|---|
nClassID | A class ID according to the schema CX_CLASS_ID (for example, CX_STAFF_MEMBER) | ||||
nMode | The parameter mode controls whether the entire database or only the active segment of the class is searched. The values are shown in the following table.
|
CollectObjects2
The objects are collected with a ClassiX®-own routine, whereby address space overflow is handled. Like CollectObjects(), the first parameter determines the class. The second parameter controls whether objects derived from this class are also collected.
The function CollectObjects2 starts and ends transactions independently. No transaction must be open before the call, otherwise the maximum release of address space after an overflow is not possible!
The result is a ("normal") reference-based collection, which can also be suspended across transaction boundaries.
The entire database is always searched.
Syntax:
nClassID bInheritance GetManager(OBJECT) Call(CollectObjects2) -> collFoundObjects
Name | Meaning | ||||
---|---|---|---|---|---|
nClassID | A class ID according to the schema CX_CLASS_ID (for example, CX_STAFF_MEMBER) | ||||
bInheritance | The parameter mode controls whether the entire database or only the active segment of the class is searched. The values are shown in the following table.
|
CollectObjects3
The objects are collected with a ClassiX®-own routine, whereby address space overflow is handled.
The function CollectObjects3 starts and ends transactions independently. No transaction must be open before the call, otherwise the maximum release of address space after an overflow is not possible!
The result is a ("normal") reference-based collection with a maximum of nMaxElements objects, which can also be resolved across transaction boundaries. Once this collection has been processed, the next nMaxElements objects can be given with a new call of CollectObjects3(). If the result collection is empty, the database search has been successfully completed.
The entire database is always searched.
Syntax:
nCmd nMaxElements nClassID bInheritance GetManager(OBJECT) Call(CollectObjects2) -> collFoundObjects
Name | Meaning | ||||||
---|---|---|---|---|---|---|---|
bInheritance | The parameter mode controls whether the entire database or only the active segment of the class is searched. The values are shown in the following table.
| ||||||
nClassID | A class ID according to the schema CX_CLASS_ID (for example, CX_STAFF_MEMBER) | ||||||
nMaxElements | An integer value that determines the maximum size of the result collection. | ||||||
nCmd | Determines the mode in which CollectObjects3() should be executed on the next call. The values are shown in the following table.
|
Code examples
// hier wird der CollectObjects2 gestartet MIT Inheritance
// das Ergebnis ist eine Collection mit allen gefundenen Objekten,
// also auch den von CX_TELECOM abgeleiteten !!!
CX_TELECOM TRUE GetManager(OBJECT) Call(CollectObject2)
iterate
{
// hier wird etwas mit den gesammelten Objekten getan.
// z.B. ein Reorg, Retype, oder ähnliches
}
;
Define (Beispiel_fuer_CollectObjects3)
Var(CO3_NORMAL, CO3_RESET, CO3_REPEAT, nMode)
0 -> CO3_NORMAL
1 -> CO3_RESET
2 -> CO3_REPEAT
// Modus für den ersten Aufruf muss CO3_RESET sein
CO3_RESET -> nMode
do {
// hier wird der CollectObjects3 gestartet OHNE Inheritance
// das Ergebnis ist eine Collection mit maximal 5000 Objekten
nMode 5000 CX_ATTRIBUTE_SET FALSE GetManager(OBJECT) Call(CollectObject3)
// Modus für folgende Aufrufe auf CO3_NORMAL setzen
CO3_NORMAL -> nMode
// Test, ob das Durchsuchen beendet ist...
Dup if Cardinality 0 = if
{ Drop break }
// Bearbeiten der Ergebnis Collection
iterate
{
// hier wird etwas mit den gesammelten Objekten getan.
// z.B. ein Reorg, Retype, oder ähnliches
}
} loop
;